#!/bin/bash
set -e
set -x
MYDIR="${0%/*}"
cd "$MYDIR/.."
source "recipes/common.sh"


# RECIPE START rpm
#
# depends: acl
# depends: elfutils
# depends: file
# depends: libcap
# depends: libdb4.7
# depends: libgcrypt
# depends: popt
# depends: xz
# depends: zlib

reset_mtime rpm rpm/configure.ac
rm -rf build/rpm
mkdir -p build/rpm
cd build/rpm
env \
	LDFLAGS="-Wl,-rpath-link -Wl,`pwd`/rpmio/.libs $LDFLAGS" \
	WITH_LIBGCRYPT_INCLUDE="-I${stage}${prefix}/include" \
	WITH_LIBGCRYPT_LIB="-lgcrypt" \
	_PRIORITY_DISTBRANCH=p10 \
../../rpm/configure \
	${CONFIGURE_ARGS} \
	--with-vendor=alt \
	--with-external-db \
	--disable-plugins \
	--without-lua \
	--without-selinux \
	--with-crypt=libgcrypt \
	--with-cap \
	--with-acl \
	--without-archive \
	--disable-python \
	${AUTOCRAP_KLUDGE}

make -j${JOBS}
make -j${JOBS} install DESTDIR=`pwd`/inst
wipe_la_files "`pwd`/inst"
rm -f inst${prefix}/bin/gendiff
rm -f inst${prefix}/bin/rpmbuild
find inst${prefix}/lib/rpm -type f -name 'brp-*' -delete
find inst${prefix}/lib/rpm -type f -name 'check-*' -delete
find inst${prefix}/lib/rpm -type f -name '*provides*' -delete
find inst${prefix}/lib/rpm -type f -name '*requires*' -delete
find inst${prefix}/lib/rpm -type f -name '*deps*' -delete
find inst${prefix}/lib/rpm -type f -name '*.prov' -delete
find inst${prefix}/lib/rpm -type f -name '*.req' -delete
rm -f inst${prefix}/lib/rpm/find-lang.h
rm -f inst${prefix}/lib/rpm/mkinstalldirs
rm -f inst${prefix}/lib/rpm/rpm2cpio.sh
rm -f inst${prefix}/lib/rpm/rpmb
rm -f inst${prefix}/share/man/man1/gendiff.1
rm -f inst${prefix}/share/man/man8/rpmbuild.8
rm -f inst${prefix}/share/man/man8/rpmdeps.8

cd inst
find . | cpio -pumd "$stage"
cd ../../..
rm -rf build/rpm

# RECIPE END rpm
